********************************************************************************
*                    DATASET CREATION REPLICATION DO FILE                      *    
*                                    for                                       * 
*                                                                              *
*    Triggering Populist Support in Europe: How Internal Political Efficacy    * 
*       Shapes the Effect of Economic Vulnerability on Party Preferences       *
*                                                                              *
*                       European Political Studies                             *
*                                                                              *
*               Marija Verner, PhD (marija.verner@yale.edu)                    *
*                Pavel Bacovsky, PhD (pbacovsky@bates.edu)                     * 
*           Sarah Wilson Sokhey, PhD (sarah.sokhey@colorado.edu)               *
********************************************************************************

cd /*filepath*/                                                                 //Sets a filepath for your working directory.                                                  
use /*"/filepaht/ESS1-9e01_1.dta"*/, clear                                      //Loads the core dataset into your stata.
* download from ESS data portal: https://www.europeansocialsurvey.org/data

keep cntry essround edulvla eisced agea hinctnt hinctnta hincfel polintr psppsgv psppsgva actrolg actrolga psppipl psppipla cptppol cptppola trstprl trstlgl trstplc trstplt trstprt vote lrscale stflife stfgov stfdem imsmetn imdfetn impcntr prtvtat-prtcldua happy inwyr gincdif freehms euftf sclmeet rlgdgr gndr uemp3m cseqno dweight pspwght pweight

///* Populist Parties in each of the countries *///

/** POPULIST VOTE **/
gen pop_vote=0
la var pop_vote "Voted for a populist party in last election"
la de poplabel 0 "No" 1 "Yes", replace
la val pop_vote poplabel

gen pop_right=0 
la var pop_right "Populist right party vote"
la val pop_right poplabel

gen pop_left=0
la var pop_left "Populist left party vote"
la val pop_left poplabel

* 1) Austria
	* essround = 1 & 2
	replace pop_vote=1 if prtvtat==3
	replace pop_right=1 if prtvtat==3

	* essround = 3
	replace pop_vote=1 if prtvtaat==3
	replace pop_right=1 if prtvtaat==3
	replace pop_vote=1 if prtvtaat==4
	replace pop_right=1 if prtvtaat==4
	
	* essround = 7 & 8
	replace pop_vote=1 if prtvtbat==3
	replace pop_right=1 if prtvtbat==3
	replace pop_vote=1 if prtvtbat==4
	replace pop_right=1 if prtvtbat==4
	replace pop_vote=1 if prtvtbat==9
	replace pop_right=1 if prtvtbat==9
	
	* essround = 9
	replace pop_vote=1 if prtvtcat==3
	replace pop_right=1 if prtvtcat==3
	
* 2) Belgium
	* essround = 1
	replace pop_vote=1 if prtvtbe==8
	replace pop_right=1 if prtvtbe==8
	replace pop_vote=1 if prtvtbe==15
	replace pop_right=1 if prtvtbe==15

	* essround = 2 & 3
	replace pop_vote=1 if prtvtabe==7
	replace pop_right=1 if prtvtabe==7
	replace pop_vote=1 if prtvtabe==11
	replace pop_right=1 if prtvtabe==11

	* essround = 4
	replace pop_vote=1 if prtvtbbe==4
	replace pop_right=1 if prtvtbbe==4
	replace pop_vote=1 if prtvtbbe==7
	replace pop_right=1 if prtvtbbe==7
	replace pop_vote=1 if prtvtbbe==11
	replace pop_right=1 if prtvtbbe==11

	* essround = 5, 6, 7 & 8
	replace pop_vote=1 if prtvtcbe==4
	replace pop_right=1 if prtvtcbe==4
	replace pop_vote=1 if prtvtcbe==7
	replace pop_right=1 if prtvtcbe==7
	replace pop_vote=1 if prtvtcbe==11
	replace pop_right=1 if prtvtcbe==11
	replace pop_vote=1 if prtvtcbe==15
	replace pop_right=1 if prtvtcbe==15
	
	* essround = 9
	replace pop_vote=1 if prtvtdbe==4
	replace pop_right=1 if prtvtdbe==4
	replace pop_vote=1 if prtvtdbe==7
	replace pop_right=1 if prtvtdbe==7
	replace pop_vote=1 if prtvtdbe==11
	replace pop_right=1 if prtvtdbe==11
	replace pop_vote=1 if prtvtdbe==15
	replace pop_right=1 if prtvtdbe==15

* 3) Bulgaria
	* essround = 3
	replace pop_vote=1 if prtvtbg==10
	replace pop_right=1 if prtvtbg==10

	* essround = 4	
	replace pop_vote=1 if prtvtabg==10
	replace pop_right=1 if prtvtabg==10

	* essround = 5
	replace pop_vote=1 if prtvtbbg==1
	replace pop_right=1 if prtvtbbg==1
	replace pop_vote=1 if prtvtbbg==5
	replace pop_right=1 if prtvtbbg==5
	replace pop_vote=1 if prtvtbbg==6
	replace pop_right=1 if prtvtbbg==6

	* essround = 6
	replace pop_vote=1 if prtvtcbg==1
	replace pop_right=1 if prtvtcbg==1
	replace pop_vote=1 if prtvtcbg==3
	replace pop_right=1 if prtvtcbg==3
	replace pop_vote=1 if prtvtcbg==4
	replace pop_right=1 if prtvtcbg==4
	
	* essround = 9
	replace pop_vote=1 if prtvtdbg==1
	replace pop_right=1 if prtvtdbg==1
	replace pop_vote=1 if prtvtdbg==3
	replace pop_right=1 if prtvtdbg==3
	replace pop_vote=1 if prtvtdbg==11
	replace pop_right=1 if prtvtdbg==11

* 4) Switzerland
	* essround = 1 & 2
	replace pop_vote=1 if prtvtch==4
	replace pop_right=1 if prtvtch==4
	replace pop_vote=1 if prtvtch==11
	replace pop_right=1 if prtvtch==11
	replace pop_vote=1 if prtvtch==15
	replace pop_right=1 if prtvtch==15

	* essround = 3	
	replace pop_vote=1 if prtvtach==4
	replace pop_right=1 if prtvtach==4
	replace pop_vote=1 if prtvtach==11
	replace pop_right=1 if prtvtach==11
	replace pop_vote=1 if prtvtach==15
	replace pop_right=1 if prtvtach==15

	* essround = 4
	replace pop_vote=1 if prtvtbch==4
	replace pop_right=1 if prtvtbch==4
	replace pop_vote=1 if prtvtbch==10
	replace pop_right=1 if prtvtbch==10
	replace pop_vote=1 if prtvtbch==13
	replace pop_right=1 if prtvtbch==13

	* essround = 5
	replace pop_vote=1 if prtvtcch==4
	replace pop_right=1 if prtvtcch==4
	replace pop_vote=1 if prtvtcch==10
	replace pop_right=1 if prtvtcch==10
	replace pop_vote=1 if prtvtcch==13
	replace pop_right=1 if prtvtcch==13

	* essround = 6
	replace pop_vote=1 if prtvtdch==1
	replace pop_right=1 if prtvtdch==1
	replace pop_vote=1 if prtvtdch==10
	replace pop_right=1 if prtvtdch==10
	replace pop_vote=1 if prtvtdch==12
	replace pop_right=1 if prtvtdch==12
	replace pop_vote=1 if prtvtdch==15
	replace pop_right=1 if prtvtdch==15

	* essround = 7
	replace pop_vote=1 if prtvtech==1
	replace pop_right=1 if prtvtech==1
	replace pop_vote=1 if prtvtech==10
	replace pop_right=1 if prtvtech==10
	replace pop_vote=1 if prtvtech==12
	replace pop_right=1 if prtvtech==12

	* essround = 8
	replace pop_vote=1 if prtvtfch==1
	replace pop_right=1 if prtvtfch==1
	replace pop_vote=1 if prtvtfch==10
	replace pop_right=1 if prtvtfch==10
	
	* essround = 9
	replace pop_vote=1 if prtvtgch==1
	replace pop_right=1 if prtvtgch==1
	replace pop_vote=1 if prtvtgch==10
	replace pop_right=1 if prtvtgch==10

* 5) Cyprus
	* essround = 3, 4, & 5
	replace pop_vote=1 if prtvtcy==2
	
	* essround = 6
	replace pop_vote=1 if prtvtacy==2
	
	* essround = 9
	replace pop_vote=1 if prtvtbcy==2

* 6) Czechia
	* essround = 1 & 2
	replace pop_vote=1 if prtvtcz==12
	replace pop_right=1 if prtvtcz==12

	* essround = 4; var prtvtacz
	
	* essround = 5
	replace pop_vote=1 if prtvtbcz==6
	replace pop_right=1 if prtvtbcz==6

	* essround = 6
	replace pop_vote=1 if prtvtccz==4
	replace pop_right=1 if prtvtccz==4

	* essround = 7 & 8
	replace pop_vote=1 if prtvtdcz==4
	replace pop_right=1 if prtvtdcz==4
	replace pop_vote=1 if prtvtdcz==7
	replace pop_right=1 if prtvtdcz==7
	
	* essround = 9
	replace pop_vote=1 if prtvtecz==4
	replace pop_right=1 if prtvtecz==4
	replace pop_vote=1 if prtvtecz==8
	replace pop_right=1 if prtvtecz==8

* 7) Germany
	* essround = 1
	replace pop_vote=1 if prtvde1==5 
	replace pop_left=1 if prtvde1==5
	replace pop_vote=1 if prtvde1==6 
	replace pop_right=1 if prtvde1==6

	* essround = 2
	replace pop_vote=1 if prtvade1==5 
	replace pop_left=1 if prtvade1==5
	replace pop_vote=1 if prtvade1==6 
	replace pop_right=1 if prtvade1==6
	replace pop_vote=1 if prtvade1==7 
	replace pop_right=1 if prtvade1==7

	* essround = 3 & 4
	replace pop_vote=1 if prtvbde1==5 
	replace pop_left=1 if prtvbde1==5
	replace pop_vote=1 if prtvbde1==6 
	replace pop_right=1 if prtvbde1==6
	replace pop_vote=1 if prtvbde1==7 
	replace pop_right=1 if prtvbde1==7
		
	* essround = 5
	replace pop_vote=1 if prtvcde1==5 
	replace pop_left=1 if prtvcde1==5
	replace pop_vote=1 if prtvcde1==6 
	replace pop_right=1 if prtvcde1==6
	replace pop_vote=1 if prtvcde1==7 
	replace pop_right=1 if prtvcde1==7
		
	* essround = 6
	replace pop_vote=1 if prtvdde1==5 
	replace pop_left=1 if prtvdde1==5
	replace pop_vote=1 if prtvdde1==6 
	replace pop_right=1 if prtvdde1==6
	replace pop_vote=1 if prtvdde1==7 
	replace pop_right=1 if prtvdde1==7
		
	* essround = 7, 8 & 9
	replace pop_vote=1 if prtvede1==3 
	replace pop_left=1 if prtvede1==3
	replace pop_vote=1 if prtvede1==6
	replace pop_right=1 if prtvede1==6
	replace pop_vote=1 if prtvede1==8 
	replace pop_right=1 if prtvede1==8
		
	* essround = 1
	replace pop_vote=1 if prtvde2==5 
	replace pop_left=1 if prtvde2==5
	replace pop_vote=1 if prtvde2==6 
	replace pop_right=1 if prtvde2==6	

	* essround = 2
	replace pop_vote=1 if prtvade2==5 
	replace pop_left=1 if prtvade2==5
	replace pop_vote=1 if prtvade2==6 
	replace pop_right=1 if prtvade2==6
	replace pop_vote=1 if prtvade2==7 
	replace pop_right=1 if prtvade2==7

	* essround = 3 & 4
	replace pop_vote=1 if prtvbde2==5 
	replace pop_left=1 if prtvbde2==5
	replace pop_vote=1 if prtvbde2==6 
	replace pop_right=1 if prtvbde2==6
	replace pop_vote=1 if prtvbde2==7 
	replace pop_right=1 if prtvbde2==7
		
	* essround = 5
	replace pop_vote=1 if prtvcde2==5 
	replace pop_left=1 if prtvcde2==5
	replace pop_vote=1 if prtvcde2==6 
	replace pop_right=1 if prtvcde2==6
	replace pop_vote=1 if prtvcde2==7 
	replace pop_right=1 if prtvcde2==7

	* essround = 6
	replace pop_vote=1 if prtvdde2==5 
	replace pop_left=1 if prtvdde2==5
	replace pop_vote=1 if prtvdde2==6 
	replace pop_right=1 if prtvdde2==6
	replace pop_vote=1 if prtvdde2==7 
	replace pop_right=1 if prtvdde2==7

	* essround = 7, 8 & 9
	replace pop_vote=1 if prtvede2==3 
	replace pop_left=1 if prtvede2==3
	replace pop_vote=1 if prtvede2==6
	replace pop_right=1 if prtvede2==6
	replace pop_vote=1 if prtvede2==8 
	replace pop_right=1 if prtvede2==8

* 8) Denmark
	* essround = 1 & 2
	replace pop_vote=1 if prtvtdk==6
	replace pop_right=1 if prtvtdk==6
	replace pop_vote=1 if prtvtdk==9
	replace pop_right=1 if prtvtdk==9

	* essround = 3
	replace pop_vote=1 if prtvtadk==6
	replace pop_right=1 if prtvtadk==6
	replace pop_vote=1 if prtvtadk==9
	replace pop_right=1 if prtvtadk==9

	* essround = 4 & 5
	replace pop_vote=1 if prtvtbdk==5
	replace pop_right=1 if prtvtbdk==5

	* essround = 6 & 7 
	replace pop_vote=1 if prtvtcdk==5
	replace pop_right=1 if prtvtcdk==5
	
	* essround = 9
	replace pop_vote=1 if prtvtddk==5
	replace pop_right=1 if prtvtddk==5
	
* 9) Estonia: No supply of credible populist parties in the period studied.
	drop if cntr == "EE"

* 10) Spain
	* essround = 6 & 7 (prtvtces). No populist parties.

	* essround = 8
	replace pop_vote=1 if prtvtdes==3 
	replace pop_left=1 if prtvtdes==3
	replace pop_vote=1 if prtvtdes==5 
	replace pop_left=1 if prtvtdes==5
	
	* essround = 9
	replace pop_vote=1 if prtvtees==3 
	replace pop_left=1 if prtvtees==3
	replace pop_vote=1 if prtvtees==5 
	replace pop_left=1 if prtvtees==5
	replace pop_vote=1 if prtvtees==16
	replace pop_right=1 if prtvtees==16

* 11) Finland
	* essround = 1, 2 & 3
	replace pop_vote=1 if prtvtfi==5 
	replace pop_right=1 if prtvtfi==5
		
	* essround = 4	
	replace pop_vote=1 if prtvtafi==5 
	replace pop_right=1 if prtvtafi==5
	
	* essround = 5
	replace pop_vote=1 if prtvtbfi==5 
	replace pop_right=1 if prtvtbfi==5

	* essround = 6 & 7
	replace pop_vote=1 if prtvtcfi==4 
	replace pop_right=1 if prtvtcfi==4

	* essround = 8 & 9
	replace pop_vote=1 if prtvtdfi==4 
	replace pop_right=1 if prtvtdfi==4

* 12) France
	* essround = 1 & 2
	replace pop_vote=1 if prtvtfr==3 
	replace pop_right=1 if prtvtfr==3

	* essround = 3
	replace pop_vote=1 if prtvtafr==3 
	replace pop_right=1 if prtvtafr==3

	* essround = 4 & 5
	replace pop_vote=1 if prtvtbfr==2 
	replace pop_right=1 if prtvtbfr==2

	* essround = 6, 7 & 8
	replace pop_vote=1 if prtvtcfr==2 
	replace pop_right=1 if prtvtcfr==2
	
	* essround = 9
	replace pop_vote=1 if prtvtdfr==10
	replace pop_right=1 if prtvtdfr==10
	replace pop_vote=1 if prtvtdfr==11
	replace pop_right=1 if prtvtdfr==11

* 13) Great Britain
	* essround = 3
	replace pop_vote=1 if prtvtagb==7
	replace pop_right=1 if prtvtagb==7
	replace pop_vote=1 if prtvtagb==8
	replace pop_right=1 if prtvtagb==8

	* essround = 7 & 8
	replace pop_vote=1 if prtvtbgb==7
	replace pop_right=1 if prtvtbgb==7
	
	* essround = 9
	replace pop_vote=1 if prtvtcgb==7
	replace pop_right=1 if prtvtcgb==7
	
	* prtvtgb missing

* 14) Greece
	* essround = 1
	replace pop_vote=1 if prtvtgr==4
	replace pop_left=1 if prtvtgr==4

	* essround = 2
	replace pop_vote=1 if prtvtagr==4
	replace pop_left=1 if prtvtagr==4
	replace pop_vote=1 if prtvtagr==6
	replace pop_right=1 if prtvtagr==6

	* essround = 4
	replace pop_vote=1 if prtvtbgr==4
	replace pop_right=1 if prtvtbgr==4
	replace pop_vote=1 if prtvtbgr==5
	replace pop_left=1 if prtvtbgr==5
	
	* essround = 5
	replace pop_vote=1 if prtvtcgr==4
	replace pop_right=1 if prtvtcgr==4
	replace pop_vote=1 if prtvtcgr==5
	replace pop_left=1 if prtvtcgr==5
	replace pop_vote=1 if prtvtcgr==10
	replace pop_right=1 if prtvtcgr==10

* 15) Croatia
	* essround = 4 & 5
	replace pop_vote=1 if prtvthr==9
	replace pop_right=1 if prtvthr==9
	
	* essround = 9
	replace pop_vote=1 if prtvtahr==4
	replace pop_vote=1 if prtvtahr==5
	replace pop_left=1 if prtvtahr==5
	replace pop_vote=1 if prtvtahr==7
	replace pop_right=1 if prtvtahr==7

* 16) Hungary - Fidesz is populist from 2006.
	* essround = 3
	replace pop_vote=1 if prtvtahu==3
	replace pop_right=1 if prtvtahu==3
	replace pop_vote=1 if prtvtahu==5
	replace pop_right=1 if prtvtahu==5

	* essround = 4
	replace pop_vote=1 if prtvtbhu==1
	replace pop_right=1 if prtvtbhu==1
	replace pop_vote=1 if prtvtbhu==3
	replace pop_right=1 if prtvtbhu==3

	* essround = 5
	replace pop_vote=1 if prtvtchu==1
	replace pop_right=1 if prtvtchu==1
	replace pop_vote=1 if prtvtchu==3
	replace pop_right=1 if prtvtchu==3
	replace pop_vote=1 if prtvtchu==11
	replace pop_right=1 if prtvtchu==11

	* essround = 6
	replace pop_vote=1 if prtvtdhu==3
	replace pop_right=1 if prtvtdhu==3
	replace pop_vote=1 if prtvtdhu==4
	replace pop_right=1 if prtvtdhu==4
	replace pop_vote=1 if prtvtdhu==7
	replace pop_right=1 if prtvtdhu==7

	* essround = 7 & 8
	replace pop_vote=1 if prtvtehu==1
	replace pop_right=1 if prtvtehu==1
	replace pop_vote=1 if prtvtehu==2
	replace pop_right=1 if prtvtehu==2
	
	* essround = 9
	replace pop_vote=1 if prtvtfhu==3
	replace pop_right=1 if prtvtfhu==3
	replace pop_vote=1 if prtvtfhu==4
	replace pop_right=1 if prtvtfhu==4
		
* 17) Ireland
	* essround = 1, 2, 3 & 4
	replace pop_vote=1 if prtvtie==6
	replace pop_left=1 if prtvtie==6

	* essround = 5, 6 & 7
	replace pop_vote=1 if prtvtaie==6
	replace pop_left=1 if prtvtaie==6
	replace pop_vote=1 if prtvtaie==7
	replace pop_left=1 if prtvtaie==7
	
	* essround = 8
	replace pop_vote=1 if prtvtbie==1
	replace pop_left=1 if prtvtbie==1
	replace pop_vote=1 if prtvtbie==7
	replace pop_left=1 if prtvtbie==7
	
	* essround = 9
	replace pop_vote=1 if prtvtcie==1
	replace pop_left=1 if prtvtcie==1
	replace pop_vote=1 if prtvtcie==7
	replace pop_left=1 if prtvtcie==7

* 18) Israel
	* essround = 1
	replace pop_vote=1 if prtvtil==3
	replace pop_right=1 if prtvtil==3
	replace pop_vote=1 if prtvtil==7
	replace pop_left=1 if prtvtil==7
	replace pop_vote=1 if prtvtil==9
	replace pop_right=1 if prtvtil==9
	replace pop_vote=1 if prtvtil==16
	replace pop_right=1 if prtvtil==16
	replace pop_vote=1 if prtvtil==31
	replace pop_left=1 if prtvtil==31

	* essround = 4
	replace pop_vote=1 if prtvtail==4
	replace pop_right=1 if prtvtail==4
	replace pop_vote=1 if prtvtail==10
	replace pop_left=1 if prtvtail==10

	* essround = 5 & 6
	replace pop_vote=1 if prtvtbil==4
	replace pop_right=1 if prtvtbil==4
	replace pop_vote=1 if prtvtbil==10
	replace pop_right=1 if prtvtbil==10
	replace pop_vote=1 if prtvtbil==14
	replace pop_left=1 if prtvtbil==14

	* essround = 7 & 8
	replace pop_vote=1 if prtvtcil==4
	replace pop_right=1 if prtvtcil==4
	replace pop_vote=1 if prtvtcil==11
	replace pop_left=1 if prtvtcil==11

* 19) Iceland
	* essround = 2
	replace pop_vote=1 if prtvtais==6
	replace pop_left=1 if prtvtais==6

	* essround = 8
	replace pop_vote=1 if prtvtbis==2
	replace pop_right=1 if prtvtbis==2
	replace pop_vote=1 if prtvtbis==4
	replace pop_left=1 if prtvtbis==4
	replace pop_vote=1 if prtvtbis==7
	replace pop_left=1 if prtvtbis==7

	* essround = 9
	replace pop_vote=1 if prtvtcis==2
	replace pop_right=1 if prtvtcis==2
	replace pop_vote=1 if prtvtcis==13
	replace pop_left=1 if prtvtcis==13
	replace pop_vote=1 if prtvtcis==10
	replace pop_left=1 if prtvtcis==10
	replace pop_vote=1 if prtvtcis==8
	
* 20) Italy
	* essround = 1
	replace pop_vote=1 if prtvtit==3
	replace pop_left=1 if prtvtit==3
	replace pop_vote=1 if prtvtit==7
	replace pop_left=1 if prtvtit==7
	replace pop_vote=1 if prtvtit==8
	replace pop_right=1 if prtvtit==8
	replace pop_vote=1 if prtvtit==9
	replace pop_right=1 if prtvtit==9
	replace pop_vote=1 if prtvtit==11
	replace pop_right=1 if prtvtit==11
	replace pop_vote=1 if prtvtit==13
	replace pop_vote=1 if prtvtit==16
	replace pop_right=1 if prtvtit==16

	* no observations?
	replace pop_vote=1 if prtvtait==3
	replace pop_left=1 if prtvtait==3
	replace pop_vote=1 if prtvtait==7
	replace pop_left=1 if prtvtait==7
	replace pop_vote=1 if prtvtait==8
	replace pop_right=1 if prtvtait==8
	replace pop_vote=1 if prtvtait==9
	replace pop_right=1 if prtvtait==9
	replace pop_vote=1 if prtvtait==11
	replace pop_right=1 if prtvtait==11
	replace pop_vote=1 if prtvtait==13
	replace pop_vote=1 if prtvtait==16
	replace pop_right=1 if prtvtait==16

	* essround = 6 & 8
	replace pop_vote=1 if prtvtbit==3
	replace pop_left=1 if prtvtbit==3
	replace pop_vote=1 if prtvtbit==4
	replace pop_vote=1 if prtvtbit==8
	replace pop_right=1 if prtvtbit==8
	replace pop_vote=1 if prtvtbit==9
	replace pop_right=1 if prtvtbit==9
	replace pop_vote=1 if prtvtbit==10
	replace pop_right=1 if prtvtbit==10
	
	* essround = 9
	replace pop_vote=1 if prtvtcit==7
	replace pop_vote=1 if prtvtcit==8
	replace pop_right=1 if prtvtcit==8
	replace pop_vote=1 if prtvtcit==9
	replace pop_right=1 if prtvtcit==9
	replace pop_vote=1 if prtvtcit==12
	replace pop_left=1 if prtvtcit==12
		
* 21) Lithuania 
	* essround = 5
	replace pop_vote=1 if prtvlt1==3
	replace pop_left=1 if prtvlt1==3
	replace pop_vote=1 if prtvlt1==13
	replace pop_right=1 if prtvlt1==13
	replace pop_vote=1 if prtvlt1==15
	replace pop_right=1 if prtvlt1==15

	* essround = 6 & 7
	replace pop_vote=1 if prtvalt1==9
	replace pop_right=1 if prtvalt1==9
	replace pop_vote=1 if prtvalt1==15
	replace pop_right=1 if prtvalt1==15

	* essround = 8 & 9
	replace pop_vote=1 if prtvblt1==4
	replace pop_right=1 if prtvblt1==4
	replace pop_vote=1 if prtvblt1==5
	replace pop_right=1 if prtvblt1==5

	* essround = 5
	replace pop_vote=1 if prtvlt2==3
	replace pop_left=1 if prtvlt2==3
	replace pop_vote=1 if prtvlt2==14
	replace pop_right=1 if prtvlt2==14
	replace pop_vote=1 if prtvlt2==16
	replace pop_right=1 if prtvlt2==16

	* essround = 6 & 7
	replace pop_vote=1 if prtvalt2==9
	replace pop_right=1 if prtvalt2==9
	replace pop_vote=1 if prtvalt2==18
	replace pop_right=1 if prtvalt2==18

	* essround = 8 & 9 
	replace pop_vote=1 if prtvblt2==4
	replace pop_right=1 if prtvblt2==4
	replace pop_vote=1 if prtvblt2==6
	replace pop_right=1 if prtvblt2==6

	* essround = 5
	replace pop_vote=1 if prtvlt3==3
	replace pop_left=1 if prtvlt3==3
	replace pop_vote=1 if prtvlt3==14
	replace pop_right=1 if prtvlt3==14
	replace pop_vote=1 if prtvlt3==16
	replace pop_right=1 if prtvlt3==16

	* essround = 6 & 7
	replace pop_vote=1 if prtvalt3==9
	replace pop_right=1 if prtvalt3==9
	replace pop_vote=1 if prtvalt3==18
	replace pop_right=1 if prtvalt3==18

	* essround = 8 & 9
	replace pop_vote=1 if prtvblt3==4
	replace pop_right=1 if prtvblt3==4
	replace pop_vote=1 if prtvblt3==6
	replace pop_right=1 if prtvblt3==6

* 22) Luxembourg
	* essround = 1 & 2
	replace pop_vote=1 if prtvtlu==5
	replace pop_left=1 if prtvtlu==5
		
* 23) Netherlands
	* essround = 1
	replace pop_vote=1 if prtvtnl==4
	replace pop_right=1 if prtvtnl==4
	replace pop_vote=1 if prtvtnl==9
	replace pop_right=1 if prtvtnl==9

	* essround = 2
	replace pop_vote=1 if prtvtanl==4
	replace pop_right=1 if prtvtanl==4
	replace pop_vote=1 if prtvtanl==9
	replace pop_right=1 if prtvtanl==9

	* essround = 3
	replace pop_vote=1 if prtvtbnl==4
	replace pop_right=1 if prtvtbnl==4
	replace pop_vote=1 if prtvtbnl==9
	replace pop_right=1 if prtvtbnl==9

	* essround = 4
	replace pop_vote=1 if prtvtcnl==4
	replace pop_right=1 if prtvtcnl==4
	replace pop_vote=1 if prtvtcnl==9
	replace pop_right=1 if prtvtcnl==9
	replace pop_vote=1 if prtvtcnl==11
	replace pop_right=1 if prtvtcnl==11

	* essround = 5
	replace pop_vote=1 if prtvtdnl==3
	replace pop_right=1 if prtvtdnl==3

	* essround = 6
	replace pop_vote=1 if prtvtenl==3
	replace pop_right=1 if prtvtenl==3

	* essround = 7 & 8
	replace pop_vote=1 if prtvtfnl==3
	replace pop_right=1 if prtvtfnl==3
	
	* essround = 9 
	replace pop_vote=1 if prtvtgnl==3
	replace pop_right=1 if prtvtgnl==3
			
* 24) Norway
	* essround = 1, 2, 3 & 4
	replace pop_vote=1 if prtvtno==1
	replace pop_left=1 if prtvtno==1
	replace pop_vote=1 if prtvtno==8
	replace pop_right=1 if prtvtno==8

	* essround = 5 & 6
	replace pop_vote=1 if prtvtano==1
	replace pop_left=1 if prtvtano==1
	replace pop_vote=1 if prtvtano==8
	replace pop_right=1 if prtvtano==8
	
	* essround = 7, 8 & 9
	replace pop_vote=1 if prtvtbno==1
	replace pop_left=1 if prtvtbno==1
	replace pop_vote=1 if prtvtbno==8
	replace pop_right=1 if prtvtbno==8

* 25) Poland
	* essround = 1 & 2
	replace pop_vote=1 if prtvtpl==4
	replace pop_left=1 if prtvtpl==4
	replace pop_vote=1 if prtvtpl==10
	replace pop_right=1 if prtvtpl==10

	* essround = 3
	replace pop_vote=1 if prtvtapl==3
	replace pop_right=1 if prtvtapl==3
	replace pop_vote=1 if prtvtapl==8
	replace pop_right=1 if prtvtapl==8
	replace pop_vote=1 if prtvtapl==14
	replace pop_right=1 if prtvtapl==14
	replace pop_vote=1 if prtvtapl==16
	replace pop_left=1 if prtvtapl==16

	* essround = 4 & 5
	replace pop_vote=1 if prtvtbpl==2
	replace pop_right=1 if prtvtbpl==2
	replace pop_vote=1 if prtvtbpl==5
	replace pop_left=1 if prtvtbpl==5
	replace pop_vote=1 if prtvtbpl==6
	replace pop_right=1 if prtvtbpl==6
	replace pop_vote=1 if prtvtbpl==7
	replace pop_left=1 if prtvtbpl==7

	* essround = 6 & 7 
	replace pop_vote=1 if prtvtcpl==1
	replace pop_right=1 if prtvtcpl==1
	replace pop_vote=1 if prtvtcpl==5
	replace pop_left=1 if prtvtcpl==5
	replace pop_vote=1 if prtvtcpl==6
	replace pop_right=1 if prtvtcpl==6
	replace pop_vote=1 if prtvtcpl==7
	replace pop_right=1 if prtvtcpl==7

	* essround = 8 & 9
	replace pop_vote=1 if prtvtdpl==1
	replace pop_right=1 if prtvtdpl==1
	replace pop_vote=1 if prtvtdpl==2
	replace pop_right=1 if prtvtdpl==2
	replace pop_vote=1 if prtvtdpl==5
	replace pop_left=1 if prtvtdpl==5
	replace pop_vote=1 if prtvtdpl==6
	replace pop_right=1 if prtvtdpl==6

* 26) Portugal
	* essround = 1 & 2
	replace pop_vote=1 if prtvtpt==1
	replace pop_left=1 if prtvtpt==1
	replace pop_vote=1 if prtvtpt==7
	replace pop_right=1 if prtvtpt==7

	* essround = 3 & 4
	replace pop_vote=1 if prtvtapt==1
	replace pop_left=1 if prtvtapt==1
	replace pop_vote=1 if prtvtapt==5
	replace pop_right=1 if prtvtapt==5
	replace pop_vote=1 if prtvtapt==8
	replace pop_right=1 if prtvtapt==8	
		
	* essround = 5, 6 & 7
	replace pop_vote=1 if prtvtbpt==1
	replace pop_left=1 if prtvtbpt==1
	replace pop_vote=1 if prtvtbpt==3
	replace pop_left=1 if prtvtbpt==3
	replace pop_vote=1 if prtvtbpt==5
	replace pop_right=1 if prtvtbpt==5
	replace pop_vote=1 if prtvtbpt==8
	replace pop_right=1 if prtvtbpt==8	
		
	* essround = 8 & 9
	replace pop_vote=1 if prtvtcpt==2
	replace pop_left=1 if prtvtcpt==2
	replace pop_vote=1 if prtvtcpt==7
	replace pop_right=1 if prtvtcpt==7
	replace pop_vote=1 if prtvtcpt==11
	replace pop_right=1 if prtvtcpt==11	
		
* 28) Sweden
	* essround = 5
	replace pop_vote=1 if prtvtase==10
	replace pop_right=1 if prtvtase==10

	* essround = 6, 7 & 8
	replace pop_vote=1 if prtvtbse==10
	replace pop_right=1 if prtvtbse==10
	
	* essround = 9
	replace pop_vote=1 if prtvtcse==9
	replace pop_right=1 if prtvtcse==9
		
* 29) Slovenia
	* essround = 1
	replace pop_vote=1 if prtvtsi==4
	replace pop_right=1 if prtvtsi==4

	* essround = 2
	replace pop_vote=1 if prtvtasi==6
	replace pop_right=1 if prtvtasi==6

	* essround = 3
	replace pop_vote=1 if prtvtbsi==4
	replace pop_right=1 if prtvtbsi==4

	* essround = 4 & 5
	replace pop_vote=1 if prtvtcsi==3
	replace pop_right=1 if prtvtcsi==3
	replace pop_vote=1 if prtvtcsi==7
	replace pop_right=1 if prtvtcsi==7

	* essround = 6
	replace pop_vote=1 if prtvtdsi==10
	replace pop_right=1 if prtvtdsi==10
	
	* essround = 7 & 8
	replace pop_vote=1 if prtvtesi==6
	replace pop_right=1 if prtvtesi==6	
	
	* essround = 9
	replace pop_vote=1 if prtvtfsi==3
	replace pop_vote=1 if prtvtfsi==8
	replace pop_right=1 if prtvtfsi==8
	replace pop_vote=1 if prtvtfsi==11
	replace pop_right=1 if prtvtfsi==11
		
* 30) Slovakia
	* essround = 2
	replace pop_vote=1 if prtvtsk==1
	replace pop_right=1 if prtvtsk==1
	replace pop_vote=1 if prtvtsk==3
	replace pop_left=1 if prtvtsk==3
	replace pop_vote=1 if prtvtsk==6
	replace pop_right=1 if prtvtsk==6
	replace pop_vote=1 if prtvtsk==7
	replace pop_left=1 if prtvtsk==7

	* essround = 3 & 4
	replace pop_vote=1 if prtvtask==1
	replace pop_right=1 if prtvtask==1
	replace pop_vote=1 if prtvtask==3
	replace pop_left=1 if prtvtask==3
	replace pop_vote=1 if prtvtask==6
	replace pop_right=1 if prtvtask==6

	* essround = 5
	replace pop_vote=1 if prtvtbsk==1
	replace pop_right=1 if prtvtbsk==1
	replace pop_vote=1 if prtvtbsk==3
	replace pop_left=1 if prtvtbsk==3

	* essround = 6
	replace pop_vote=1 if prtvtcsk==1
	replace pop_right=1 if prtvtcsk==1
	replace pop_vote=1 if prtvtcsk==3
	replace pop_left=1 if prtvtcsk==3
	
	* essround = 9
	replace pop_vote=1 if prtvtdsk==1
	replace pop_right=1 if prtvtdsk==1
	replace pop_vote=1 if prtvtdsk==3
	replace pop_left=1 if prtvtdsk==3
	replace pop_vote=1 if prtvtdsk==5
	replace pop_right=1 if prtvtdsk==5
	replace pop_vote=1 if prtvtdsk==8
	replace pop_right=1 if prtvtdsk==8

* 31) Turkey
	* essround = 2
	replace pop_vote=1 if prtvttr==8
	replace pop_vote=1 if prtvttr==9
	replace pop_right=1 if prtvttr==9
	replace pop_vote=1 if prtvttr==10
	replace pop_left=1 if prtvttr==10

	* essround = 4
	replace pop_vote=1 if prtvtatr==8
	replace pop_left=1 if prtvtatr==8
	replace pop_vote=1 if prtvtatr==9
	replace pop_left=1 if prtvtatr==9
	replace pop_vote=1 if prtvtatr==10
	replace pop_right=1 if prtvtatr==10
	replace pop_vote=1 if prtvtatr==11
	replace pop_left=1 if prtvtatr==11
		
* 32) Ukraine
	* essround = 2
	replace pop_vote=1 if prtvtua==1
	replace pop_left=1 if prtvtua==1
	replace pop_vote=1 if prtvtua==5
	replace pop_left=1 if prtvtua==5
	replace pop_vote=1 if prtvtua==8
	replace pop_left=1 if prtvtua==8
	replace pop_vote=1 if prtvtua==12
	replace pop_left=1 if prtvtua==12
	replace pop_vote=1 if prtvtua==25
	replace pop_right=1 if prtvtua==25

	* essround = 3
	replace pop_vote=1 if prtvtaua==5
	replace pop_left=1 if prtvtaua==5
	replace pop_vote=1 if prtvtaua==6
	replace pop_left=1 if prtvtaua==6

	* essround = 4 & 5
	replace pop_vote=1 if prtvtbua==4
	replace pop_left=1 if prtvtbua==4
	replace pop_vote=1 if prtvtbua==6
	replace pop_left=1 if prtvtbua==6

	* essround = 6
	replace pop_vote=1 if prtvtcua==2
	replace pop_right=1 if prtvtcua==2
	replace pop_vote=1 if prtvtcua==3
	replace pop_left=1 if prtvtcua==3

/** POPULIST CLOSENESS **/

gen pop_close=0
la var pop_close "Close to a populist party"
la val pop_close poplabel
gen pcl_left=0
la var pcl_left "Close to left populist party"
la val pcl_left poplabel
gen pcl_right=0
la var pcl_right "Close to right populist party"
la val pcl_right poplabel

* 1) Austria
	* essround = 1 & 2
	replace pop_close=1 if prtclat==3
	replace pcl_right=1 if prtclat==3

	* essround = 3
	replace pop_close=1 if prtclaat==3
	replace pcl_right=1 if prtclaat==3
	replace pop_close=1 if prtclaat==4
	replace pcl_right=1 if prtclaat==4
	
	* essround = 7 & 8
	replace pop_close=1 if prtclcat==3
	replace pcl_right=1 if prtclcat==3
	replace pop_close=1 if prtclcat==4
	replace pcl_right=1 if prtclcat==4
	replace pop_close=1 if prtclcat==9
	replace pcl_right=1 if prtclcat==9
	
	* essround = 9
	replace pop_close=1 if prtcldat==3
	replace pcl_right=1 if prtcldat==3
	
* 2) Belgium
	* essround = 1
	replace pop_close=1 if prtclbe==8
	replace pcl_right=1 if prtclbe==8
	replace pop_close=1 if prtclbe==15
	replace pcl_right=1 if prtclbe==15

	* essround = 2 & 3
	replace pop_close=1 if prtclabe==7
	replace pcl_right=1 if prtclabe==7
	replace pop_close=1 if prtclabe==11
	replace pcl_right=1 if prtclabe==11

	* essround = 4
	replace pop_close=1 if prtclbbe==4
	replace pcl_right=1 if prtclbbe==4
	replace pop_close=1 if prtclbbe==7
	replace pcl_right=1 if prtclbbe==7
	replace pop_close=1 if prtclbbe==11
	replace pcl_right=1 if prtclbbe==11

	* essround = 5, 6, 7 & 8
	replace pop_close=1 if prtclcbe==4
	replace pcl_right=1 if prtclcbe==4
	replace pop_close=1 if prtclcbe==7
	replace pcl_right=1 if prtclcbe==7
	replace pop_close=1 if prtclcbe==11
	replace pcl_right=1 if prtclcbe==11
	replace pop_close=1 if prtclcbe==15
	replace pcl_right=1 if prtclcbe==15
	
	* essround = 9
	replace pop_close=1 if prtcldbe==4
	replace pcl_right=1 if prtcldbe==4
	replace pop_close=1 if prtcldbe==7
	replace pcl_right=1 if prtcldbe==7
	replace pop_close=1 if prtcldbe==11
	replace pcl_right=1 if prtcldbe==11
	replace pop_close=1 if prtcldbe==15
	replace pop_right=1 if prtcldbe==15

* 3) Bulgaria
	* essround = 3
	replace pop_close=1 if prtclbg==10
	replace pcl_right=1 if prtclbg==10

	* essround = 4	
	replace pop_close=1 if prtclabg==10
	replace pcl_right=1 if prtclabg==10

	* essround = 5
	replace pop_close=1 if prtclbbg==1
	replace pcl_right=1 if prtclbbg==1
	replace pop_close=1 if prtclbbg==5
	replace pcl_right=1 if prtclbbg==5
	replace pop_close=1 if prtclbbg==6
	replace pcl_right=1 if prtclbbg==6

	* essround = 6
	replace pop_close=1 if prtclcbg==1
	replace pcl_right=1 if prtclcbg==1
	replace pop_close=1 if prtclcbg==3
	replace pcl_right=1 if prtclcbg==3
	replace pop_close=1 if prtclcbg==4
	replace pcl_right=1 if prtclcbg==4
	
	* essround = 9
	replace pop_close=1 if prtcldbg==1
	replace pcl_right=1 if prtcldbg==1
	replace pop_close=1 if prtcldbg==3
	replace pcl_right=1 if prtcldbg==3
	replace pop_close=1 if prtcldbg==11
	replace pcl_right=1 if prtcldbg==11

* 4) Switzerland
	* essround = 1 & 2
	replace pop_close=1 if prtclch==4
	replace pcl_right=1 if prtclch==4
	replace pop_close=1 if prtclch==11
	replace pcl_right=1 if prtclch==11
	replace pop_close=1 if prtclch==15
	replace pcl_right=1 if prtclch==15

	* essround = 3	
	replace pop_close=1 if prtclach==4
	replace pcl_right=1 if prtclach==4
	replace pop_close=1 if prtclach==11
	replace pcl_right=1 if prtclach==11
	replace pop_close=1 if prtclach==15
	replace pcl_right=1 if prtclach==15

	* essround = 4
	replace pop_close=1 if prtclbch==4
	replace pcl_right=1 if prtclbch==4
	replace pop_close=1 if prtclbch==10
	replace pcl_right=1 if prtclbch==10
	replace pop_close=1 if prtclbch==13
	replace pcl_right=1 if prtclbch==13

	* essround = 5
	replace pop_close=1 if prtclcch==4
	replace pcl_right=1 if prtclcch==4
	replace pop_close=1 if prtclcch==10
	replace pcl_right=1 if prtclcch==10
	replace pop_close=1 if prtclcch==13
	replace pcl_right=1 if prtclcch==13

	* essround = 6
	replace pop_close=1 if prtcldch==1
	replace pcl_right=1 if prtcldch==1
	replace pop_close=1 if prtcldch==10
	replace pcl_right=1 if prtcldch==10
	replace pop_close=1 if prtcldch==12
	replace pcl_right=1 if prtcldch==12
	replace pop_close=1 if prtcldch==15
	replace pcl_right=1 if prtcldch==15

	* essround = 7
	replace pop_close=1 if prtclech==1
	replace pcl_right=1 if prtclech==1
	replace pop_close=1 if prtclech==10
	replace pcl_right=1 if prtclech==10
	replace pop_close=1 if prtclech==12
	replace pcl_right=1 if prtclech==12

	* essround = 8
	replace pop_close=1 if prtclfch==1
	replace pcl_right=1 if prtclfch==1
	replace pop_close=1 if prtclfch==10
	replace pcl_right=1 if prtclfch==10
	
	* essround = 9
	replace pop_close=1 if prtclgch==1
	replace pcl_right=1 if prtclgch==1
	replace pop_close=1 if prtclgch==10
	replace pcl_right=1 if prtclgch==10

* 5) Cyprus
	* essround = 3, 4, & 5
	replace pop_close=1 if prtclcy==2
	
	* essround = 6
	replace pop_close=1 if prtclacy==2
	
	* essround = 9
	replace pop_close=1 if prtclbcy==2

* 6) Czechia
	* essround = 1 & 2
	replace pop_close=1 if prtvtcz==12
	replace pcl_right=1 if prtvtcz==12

	* essround = 4; var prtvtacz
	
	* essround = 5
	replace pop_close=1 if prtclbcz==6
	replace pcl_right=1 if prtvtbcz==6

	* essround = 6
	replace pop_close=1 if prtclccz==4
	replace pcl_right=1 if prtvtccz==4

	* essround = 7 & 8
	replace pop_close=1 if prtcldcz==4
	replace pcl_right=1 if prtcldcz==4
	replace pop_close=1 if prtcldcz==7
	replace pcl_right=1 if prtcldcz==7
	
	* essround = 9
	replace pop_close=1 if prtclecz==4
	replace pcl_right=1 if prtclecz==4
	replace pop_close=1 if prtclecz==8
	replace pcl_right=1 if prtclecz==8

* 7) Germany
	* essround = 1
	replace pop_close=1 if prtclde==5 
	replace pcl_left=1 if prtclde==5
	replace pop_close=1 if prtclde==6 
	replace pcl_right=1 if prtclde==6

	* essround = 2
	replace pop_close=1 if prtclade==5 
	replace pcl_left=1 if prtclade==5
	replace pop_close=1 if prtclade==6 
	replace pcl_right=1 if prtclade==6
	replace pop_close=1 if prtclade==7 
	replace pcl_right=1 if prtclade==7

	* essround = 3 & 4
	replace pop_close=1 if prtclbde==5 
	replace pcl_left=1 if prtclbde==5
	replace pop_close=1 if prtclbde==6 
	replace pcl_right=1 if prtclbde==6
	replace pop_close=1 if prtclbde==7 
	replace pcl_right=1 if prtclbde==7
		
	* essround = 5
	replace pop_close=1 if prtclcde==5 
	replace pcl_left=1 if prtclcde==5
	replace pop_close=1 if prtclcde==6 
	replace pcl_right=1 if prtclcde==6
	replace pop_close=1 if prtclcde==7 
	replace pcl_right=1 if prtclcde==7
		
	* essround = 6
	replace pop_close=1 if prtcldde==5 
	replace pcl_left=1 if prtcldde==5
	replace pop_close=1 if prtcldde==6 
	replace pcl_right=1 if prtcldde==6
	replace pop_close=1 if prtcldde==7 
	replace pcl_right=1 if prtcldde==7
		
	* essround = 7, 8 & 9
	replace pop_close=1 if prtclede==3 
	replace pcl_left=1 if prtclede==3
	replace pop_close=1 if prtclede==6
	replace pcl_right=1 if prtclede==6
	replace pop_close=1 if prtclede==8 
	replace pcl_right=1 if prtclede==8

* 8) Denmark
	* essround = 1 & 2
	replace pop_close=1 if prtcldk==6
	replace pcl_right=1 if prtcldk==6
	replace pop_close=1 if prtcldk==9
	replace pcl_right=1 if prtcldk==9

	* essround = 3
	replace pop_close=1 if prtcladk==6
	replace pcl_right=1 if prtcladk==6
	replace pop_close=1 if prtcladk==9
	replace pcl_right=1 if prtcladk==9

	* essround = 4 & 5
	replace pop_close=1 if prtclbdk==5
	replace pcl_right=1 if prtclbdk==5

	* essround = 6 & 7 
	replace pop_close=1 if prtclcdk==5
	replace pcl_right=1 if prtclcdk==5
	
	* essround = 9
	replace pop_close=1 if prtclddk==5
	replace pcl_right=1 if prtclddk==5
	
* 9) Estonia: No supply of credible populist parties in the period studied.
	* drop if cntr == "EE"

* 10) Spain
	* essround = 7 (prtcldes). No populist parties.

	* essround = 8
	replace pop_close=1 if prtclees==3 
	replace pcl_left=1 if prtclees==3
	replace pop_close=1 if prtclees==5 
	replace pcl_left=1 if prtclees==5
	
	* essround = 9
	replace pop_close=1 if prtclfes==3 
	replace pcl_left=1 if prtclfes==3
	replace pop_close=1 if prtclfes==5 
	replace pcl_left=1 if prtclfes==5
	replace pop_close=1 if prtclfes==16
	replace pcl_right=1 if prtclfes==16

* 11) Finland
	* essround = 1, 2 & 3
	replace pop_close=1 if prtclfi==5 
	replace pcl_right=1 if prtclfi==5
		
	* essround = 4	
	replace pop_close=1 if prtclafi==5 
	replace pcl_right=1 if prtclafi==5
	
	* essround = 5
	replace pop_close=1 if prtclbfi==5 
	replace pcl_right=1 if prtclbfi==5

	* essround = 6 & 7
	replace pop_close=1 if prtclcfi==4 
	replace pcl_right=1 if prtclcfi==4

	* essround = 8
	replace pop_close=1 if prtcldfi==4 
	replace pcl_right=1 if prtcldfi==4
	
	* essround = 9
	replace pop_close=1 if prtclefi==4 
	replace pcl_right=1 if prtclefi==4

* 12) France
	* essround = 1 & 2
	replace pop_close=1 if prtclfr==3 
	replace pcl_right=1 if prtclfr==3

	* essround = 3
	replace pop_close=1 if prtclafr==3 
	replace pcl_right=1 if prtclafr==3

	* essround = 4
	replace pop_close=1 if prtclbfr==2 
	replace pcl_right=1 if prtclbfr==2
	
	* essround = 5
	replace pop_close=1 if prtclcfr==1 
	replace pcl_right=1 if prtclcfr==1
	
	* essround = 6, 7
	replace pop_close=1 if prtcldfr==2 
	replace pcl_right=1 if prtcldfr==2
	
	* essround = 8
	replace pop_close=1 if prtclefr==2 
	replace pcl_right=1 if prtclefr==2
	
	* essround = 9
	replace pop_close=1 if prtclffr==10
	replace pcl_right=1 if prtclffr==10
	replace pop_close=1 if prtclffr==11
	replace pcl_right=1 if prtclffr==11

* 13) Great Britain
	* essround = 3
	replace pop_close=1 if prtclagb==7
	replace pcl_right=1 if prtclagb==7
	replace pop_close=1 if prtclagb==8
	replace pcl_right=1 if prtclagb==8

	* essround = 7 & 8
	replace pop_close=1 if prtclbgb==7
	replace pcl_right=1 if prtclbgb==7
	
	* essround = 9
	replace pop_close=1 if prtclcgb==7
	replace pcl_right=1 if prtclcgb==7
	
	* prtvtgb missing

* 14) Greece
	* essround = 1
	replace pop_close=1 if prtclgr==4
	replace pcl_left=1 if prtclgr==4

	* essround = 2
	replace pop_close=1 if prtclagr==4
	replace pcl_left=1 if prtclagr==4
	replace pop_close=1 if prtclagr==6
	replace pcl_right=1 if prtclagr==6

	* essround = 4
	replace pop_close=1 if prtclbgr==4
	replace pcl_right=1 if prtclbgr==4
	replace pop_close=1 if prtclbgr==5
	replace pcl_left=1 if prtclbgr==5
	
	* essround = 5
	replace pop_close=1 if prtclcgr==4
	replace pcl_right=1 if prtclcgr==4
	replace pop_close=1 if prtclcgr==5
	replace pcl_left=1 if prtclcgr==5
	replace pop_close=1 if prtclcgr==12
	replace pcl_right=1 if prtclcgr==12
	
* 15) Croatia
	* essround = 4 & 5
	replace pop_close=1 if prtclhr==9
	replace pcl_right=1 if prtclhr==9
	
	* essround = 9
	replace pop_close=1 if prtclahr==4
	replace pop_close=1 if prtclahr==5
	replace pcl_left=1 if prtclahr==5
	replace pop_close=1 if prtclahr==7
	replace pcl_right=1 if prtclahr==7

* 16) Hungary - Fidesz is populist from 2006.
	* essround = 3
	replace pop_close=1 if prtclahu==3
	replace pcl_right=1 if prtclahu==3
	replace pop_close=1 if prtclahu==5
	replace pcl_right=1 if prtclahu==5

	* essround = 4
	replace pop_close=1 if prtclbhu==1
	replace pcl_right=1 if prtclbhu==1
	replace pop_close=1 if prtclbhu==3
	replace pcl_right=1 if prtclbhu==3

	* essround = 5
	replace pop_close=1 if prtclchu==1
	replace pcl_right=1 if prtclchu==1
	replace pop_close=1 if prtclchu==3
	replace pcl_right=1 if prtclchu==3
	replace pop_close=1 if prtclchu==11
	replace pcl_right=1 if prtclchu==11

	* essround = 6
	replace pop_close=1 if prtcldhu==3
	replace pcl_right=1 if prtcldhu==3
	replace pop_close=1 if prtcldhu==4
	replace pcl_right=1 if prtcldhu==4
	replace pop_close=1 if prtcldhu==7
	replace pcl_right=1 if prtcldhu==7

	* essround = 7
	replace pop_close=1 if prtclehu==1
	replace pcl_right=1 if prtclehu==1
	replace pop_close=1 if prtclehu==2
	replace pcl_right=1 if prtclehu==2
	
	* essround = 8
	replace pop_close=1 if prtclfhu==1
	replace pcl_right=1 if prtclfhu==1
	replace pop_close=1 if prtclfhu==2
	replace pcl_right=1 if prtclfhu==2
	
	* essround = 9
	replace pop_close=1 if prtclghu==3
	replace pcl_right=1 if prtclghu==3
	replace pop_close=1 if prtclghu==4
	replace pcl_right=1 if prtclghu==4
		
* 17) Ireland
	* essround = 1 & 2
	replace pop_close=1 if prtclie==6
	replace pcl_left=1 if prtclie==6
	
	* essround = 3
	replace pop_close=1 if prtclaie==6
	replace pcl_left=1 if prtclaie==6
	
	* essround = 4
	replace pop_close=1 if prtclbie==5
	replace pcl_left=1 if prtclbie==5

	* essround = 5, 6 & 7
	replace pop_close=1 if prtclcie==6
	replace pcl_left=1 if prtclcie==6
	replace pop_close=1 if prtclcie==7
	replace pcl_left=1 if prtclcie==7
	
	* essround = 8
	replace pop_close=1 if prtcldie==1
	replace pcl_left=1 if prtcldie==1
	replace pop_close=1 if prtcldie==7
	replace pcl_left=1 if prtcldie==7
	
	* essround = 9
	replace pop_close=1 if prtcleie==1
	replace pcl_left=1 if prtcleie==1
	replace pop_close=1 if prtcleie==7
	replace pcl_left=1 if prtcleie==7

* 18) Israel
	* essround = 1
	replace pop_close=1 if prtclil==3
	replace pcl_right=1 if prtclil==3
	replace pop_close=1 if prtclil==7
	replace pcl_left=1 if prtclil==7
	replace pop_close=1 if prtclil==9
	replace pcl_right=1 if prtclil==9
	replace pop_close=1 if prtclil==16
	replace pcl_right=1 if prtclil==16
	replace pop_close=1 if prtclil==31
	replace pcl_left=1 if prtclil==31

	* essround = 4
	replace pop_close=1 if prtclail==4
	replace pcl_right=1 if prtclail==4
	replace pop_close=1 if prtclail==10
	replace pcl_left=1 if prtclail==10

	* essround = 5
	replace pop_close=1 if prtclbil==4
	replace pcl_right=1 if prtclbil==4
	replace pop_close=1 if prtclbil==10
	replace pcl_right=1 if prtclbil==10
	replace pop_close=1 if prtclbil==14
	replace pcl_left=1 if prtclbil==14
	
	* essround = 6
	replace pop_close=1 if prtclcil==4
	replace pcl_right=1 if prtclcil==4
	replace pop_close=1 if prtclcil==10
	replace pcl_right=1 if prtclcil==10
	replace pop_close=1 if prtclcil==14
	replace pcl_left=1 if prtclcil==14

	* essround = 7 & 8
	replace pop_close=1 if prtclcil==4
	replace pcl_right=1 if prtclcil==4
	replace pop_close=1 if prtclcil==11
	replace pcl_left=1 if prtclcil==11

* 19) Iceland
	* essround = 2
	replace pop_close=1 if prtclis==1

	* essround = 6 (prtclais)
	
	* essround = 8
	replace pop_close=1 if prtclbis==2
	replace pcl_right=1 if prtclbis==2
	replace pop_close=1 if prtclbis==4
	replace pcl_left=1 if prtclbis==4
	replace pop_close=1 if prtclbis==7
	replace pcl_left=1 if prtclbis==7

	* essround = 9
	replace pop_close=1 if prtclcis==2
	replace pcl_right=1 if prtclcis==2
	replace pop_close=1 if prtclcis==13
	replace pcl_left=1 if prtclcis==13
	replace pop_close=1 if prtclcis==10
	replace pcl_left=1 if prtclcis==10
	replace pop_close=1 if prtclcis==8
	
* 20) Italy
	* essround = 1
	replace pop_close=1 if prtclit==3
	replace pcl_left=1 if prtclit==3
	replace pop_close=1 if prtclit==7
	replace pcl_left=1 if prtclit==7
	replace pop_close=1 if prtclit==8
	replace pcl_right=1 if prtclit==8
	replace pop_close=1 if prtclit==9
	replace pcl_right=1 if prtclit==9
	replace pop_close=1 if prtclit==11
	replace pcl_right=1 if prtclit==11
	replace pop_close=1 if prtclit==13
	replace pop_close=1 if prtclit==16
	replace pcl_right=1 if prtclit==16

	* no observations?
	replace pop_close=1 if prtclait==3
	replace pcl_left=1 if prtclait==3
	replace pop_close=1 if prtclait==7
	replace pcl_left=1 if prtclait==7
	replace pop_close=1 if prtclait==8
	replace pcl_right=1 if prtclait==8
	replace pop_close=1 if prtclait==9
	replace pcl_right=1 if prtclait==9
	replace pop_close=1 if prtclait==11
	replace pcl_right=1 if prtclait==11
	replace pop_close=1 if prtclait==13
	replace pop_close=1 if prtclait==16
	replace pcl_right=1 if prtclait==16

	* essround = 6
	replace pop_close=1 if prtclbit==3
	replace pcl_left=1 if prtclbit==3
	replace pop_close=1 if prtclbit==4
	replace pop_close=1 if prtclbit==8
	replace pcl_right=1 if prtclbit==8
	replace pop_close=1 if prtclbit==9
	replace pcl_right=1 if prtclbit==9
	replace pop_close=1 if prtclbit==10
	replace pcl_right=1 if prtclbit==10
	
	* essround = 8
	replace pop_close=1 if prtclcit==1
	replace pop_close=1 if prtclcit==3
	replace pcl_right=1 if prtclcit==3
	replace pop_close=1 if prtclcit==5
	replace pcl_right=1 if prtclcit==5
	
	* essround = 9
	replace pop_close=1 if prtcldit==7
	replace pop_close=1 if prtcldit==8
	replace pcl_right=1 if prtcldit==8
	replace pop_close=1 if prtcldit==9
	replace pcl_right=1 if prtcldit==9
	replace pop_close=1 if prtcldit==12
	replace pcl_left=1 if prtcldit==12
		
* 21) Lithuania (check voting too)
	* essround = 5
	replace pop_close=1 if prtcllt==3
	replace pcl_left=1 if prtcllt==3
	replace pop_close=1 if prtcllt==14
	replace pcl_right=1 if prtcllt==14
	replace pop_close=1 if prtcllt==16
	replace pcl_right=1 if prtcllt==16

	* essround = 6 & 7
	replace pop_close=1 if prtclalt==9
	replace pcl_right=1 if prtclalt==9
	replace pop_close=1 if prtclalt==18
	replace pcl_right=1 if prtclalt==18

	* essround = 8 & 9
	replace pop_close=1 if prtclblt==6
	replace pcl_right=1 if prtclblt==6
	replace pop_close=1 if prtclblt==15
	replace pcl_right=1 if prtclblt==15

* 22) Luxembourg
	* essround = 1 & 2
	replace pop_close=1 if prtcllu==5
	replace pcl_left=1 if prtcllu==5
		
* 23) Netherlands
	* essround = 1 & 3
	replace pop_close=1 if prtclnl==4
	replace pcl_right=1 if prtclnl==4
	replace pop_close=1 if prtclnl==9
	replace pcl_right=1 if prtclnl==9

	* essround = 2
	replace pop_close=1 if prtclanl==4
	replace pcl_right=1 if prtclanl==4
	replace pop_close=1 if prtclanl==9
	replace pcl_right=1 if prtclanl==9

	* essround = 4
	replace pop_close=1 if prtclbnl==4
	replace pcl_right=1 if prtclbnl==4
	replace pop_close=1 if prtclbnl==9
	replace pcl_right=1 if prtclbnl==9
	replace pop_close=1 if prtclbnl==11
	replace pcl_right=1 if prtclbnl==11

	* essround = 5
	replace pop_close=1 if prtclcnl==3
	replace pcl_right=1 if prtclcnl==3

	* essround = 6
	replace pop_close=1 if prtcldnl==3
	replace pcl_right=1 if prtcldnl==3

	* essround = 7 & 8
	replace pop_close=1 if prtclenl==3
	replace pcl_right=1 if prtclenl==3
	
	* essround = 9 
	replace pop_close=1 if prtclfnl==3
	replace pcl_right=1 if prtclfnl==3
			
* 24) Norway
	* essround = 1, 2, 3 & 4
	replace pop_close=1 if prtclno==1
	replace pcl_left=1 if prtclno==1
	replace pop_close=1 if prtclno==8
	replace pcl_right=1 if prtclno==8

	* essround = 5 & 6
	replace pop_close=1 if prtclano==1
	replace pcl_left=1 if prtclano==1
	replace pop_close=1 if prtclano==8
	replace pcl_right=1 if prtclano==8
	
	* essround = 7, 8 & 9
	replace pop_close=1 if prtclbno==1
	replace pcl_left=1 if prtclbno==1
	replace pop_close=1 if prtclbno==8
	replace pcl_right=1 if prtclbno==8

* 25) Poland 

	* essround = 5
	replace pop_close=1 if prtcldpl==1
	replace pcl_right=1 if prtcldpl==1
	replace pop_close=1 if prtcldpl==8
	replace pop_close=1 if prtcldpl==12
	replace pcl_right=1 if prtcldpl==12
	
	* essround = 6
	replace pop_close=1 if prtclepl==1
	replace pcl_right=1 if prtclepl==1
	replace pop_close=1 if prtclepl==5
	replace pcl_right=1 if prtclepl==5
	replace pop_close=1 if prtclepl==6
	replace pcl_right=1 if prtclepl==6
	replace pop_close=1 if prtclepl==8
	replace pcl_right=1 if prtclepl==8

	* essround = 7 
	replace pop_close=1 if prtclfpl==1
	replace pcl_right=1 if prtclfpl==1
	replace pop_close=1 if prtclfpl==5
	replace pcl_right=1 if prtclfpl==5
	replace pop_close=1 if prtclfpl==6
	replace pcl_right=1 if prtclfpl==6

	* essround = 8
	replace pop_close=1 if prtclgpl==1
	replace pcl_right=1 if prtclgpl==1
	replace pop_close=1 if prtclgpl==2
	replace pcl_right=1 if prtclgpl==2
	replace pop_close=1 if prtclgpl==6
	replace pcl_right=1 if prtclgpl==6
	
	* essround = 9
	replace pop_close=1 if prtclhpl==1
	replace pcl_right=1 if prtclhpl==1
	replace pop_close=1 if prtclhpl==5
	replace pcl_right=1 if prtclhpl==5
	
* 26) Portugal
		
	* essround = 7
	replace pop_close=1 if prtcldpt==1
	replace pcl_left=1 if prtcldpt==1
		
	* essround = 8 & 9
	replace pop_close=1 if prtclept==2
	replace pcl_left=1 if prtclept==2
	replace pop_close=1 if prtclept==7
	replace pcl_right=1 if prtclept==7
	replace pop_close=1 if prtclept==11
	replace pcl_right=1 if prtclept==11	
		
* 28) Sweden
	* essround = 5
	replace pop_close=1 if prtclase==10
	replace pcl_right=1 if prtclase==10

	* essround = 6, 7 & 8
	replace pop_close=1 if prtclbse==10
	replace pcl_right=1 if prtclbse==10
	
	* essround = 9
	replace pop_close=1 if prtclcse==9
	replace pcl_right=1 if prtclcse==9
		
* 29) Slovenia
	* essround = 1
	replace pop_close=1 if prtclsi==4
	replace pcl_right=1 if prtclsi==4

	* essround = 2
	replace pop_close=1 if prtclasi==6
	replace pcl_right=1 if prtclasi==6

	* essround = 3
	replace pop_close=1 if prtclbsi==4
	replace pcl_right=1 if prtclbsi==4

	* essround = 4 & 5
	replace pop_close=1 if prtclcsi==3
	replace pcl_right=1 if prtclcsi==3
	replace pop_close=1 if prtclcsi==7
	replace pcl_right=1 if prtclcsi==7

	* essround = 6
	replace pop_close=1 if prtcldsi==10
	replace pcl_right=1 if prtcldsi==10
	
	* essround = 7 & 8
	replace pop_close=1 if prtclesi==6
	replace pcl_right=1 if prtclesi==6	
	
	* essround = 9
	replace pop_close=1 if prtclfsi==3
	replace pop_close=1 if prtclfsi==8
	replace pcl_right=1 if prtclfsi==8
	replace pop_close=1 if prtclfsi==11
	replace pcl_right=1 if prtclfsi==11
		
* 30) Slovakia
	* essround = 2
	replace pop_close=1 if prtclsk==1
	replace pcl_right=1 if prtclsk==1
	replace pop_close=1 if prtclsk==3
	replace pcl_left=1 if prtclsk==3
	replace pop_close=1 if prtclsk==6
	replace pcl_right=1 if prtclsk==6
	replace pop_close=1 if prtclsk==7
	replace pcl_left=1 if prtclsk==7

	* essround = 3 & 4
	replace pop_close=1 if prtclask==1
	replace pcl_right=1 if prtclask==1
	replace pop_close=1 if prtclask==3
	replace pcl_left=1 if prtclask==3
	replace pop_close=1 if prtclask==6
	replace pcl_right=1 if prtclask==6

	* essround = 5
	replace pop_close=1 if prtclbsk==1
	replace pcl_right=1 if prtclbsk==1
	replace pop_close=1 if prtclbsk==3
	replace pcl_left=1 if prtclbsk==3

	* essround = 6
	replace pop_close=1 if prtclcsk==1
	replace pcl_right=1 if prtclcsk==1
	replace pop_close=1 if prtclcsk==3
	replace pcl_left=1 if prtclcsk==3
	
	* essround = 9
	replace pop_close=1 if prtcldsk==1
	replace pcl_right=1 if prtcldsk==1
	replace pop_close=1 if prtcldsk==3
	replace pcl_left=1 if prtcldsk==3
	replace pop_close=1 if prtcldsk==5
	replace pcl_right=1 if prtcldsk==5
	replace pop_close=1 if prtcldsk==8
	replace pcl_right=1 if prtcldsk==8

* 31) Turkey
	* essround = 2
	replace pop_close=1 if prtcltr==8
	replace pop_close=1 if prtcltr==9
	replace pcl_right=1 if prtcltr==9
	replace pop_close=1 if prtcltr==10
	replace pcl_left=1 if prtcltr==10

	* essround = 4
	replace pop_close=1 if prtclatr==8
	replace pcl_left=1 if prtclatr==8
	replace pop_close=1 if prtclatr==9
	replace pcl_left=1 if prtclatr==9
	replace pop_close=1 if prtclatr==10
	replace pcl_right=1 if prtclatr==10
	replace pop_close=1 if prtclatr==11
	replace pcl_left=1 if prtclatr==11
		
* 32) Ukraine
	* essround = 2
	replace pop_close=1 if prtclua==1
	replace pcl_left=1 if prtclua==1
	replace pop_close=1 if prtclua==5
	replace pcl_left=1 if prtclua==5
	replace pop_close=1 if prtclua==8
	replace pcl_left=1 if prtclua==8
	replace pop_close=1 if prtclua==12
	replace pcl_left=1 if prtclua==12
	replace pop_close=1 if prtclua==25
	replace pcl_right=1 if prtclua==25

	* essround = 3
	replace pop_close=1 if prtclaua==5
	replace pcl_left=1 if prtclaua==5
	replace pop_close=1 if prtclaua==6
	replace pcl_left=1 if prtclaua==6

	* essround = 4
	replace pop_close=1 if prtclbua==4
	replace pcl_left=1 if prtclbua==4
	replace pop_close=1 if prtclbua==6
	replace pcl_left=1 if prtclbua==6
	
	* essround = 5
	replace pop_close=1 if prtclcua==4
	replace pcl_left=1 if prtclcua==4
	replace pop_close=1 if prtclcua==6
	replace pcl_left=1 if prtclcua==6

	* essround = 6
	replace pop_close=1 if prtcldua==2
	replace pcl_right=1 if prtcldua==2
	replace pop_close=1 if prtcldua==3
	replace pcl_left=1 if prtcldua==3

/** MANAGING OTHER VARIABLES **/
* assign countries numeric values
encode cntry, gen(cntry_num)

* 1 - Austria
* 2 - Belgium
* 3 - Bulgaria
* 4 - Switzerland
* 5 - Cyprus
* 6 - Czechia
* 7 - Germany
* 8 - Denmark
* 9 - Estonia
* 10 - Spain
* 11 - Finland
* 12 - France
* 13 - United Kingdom
* 14 - Greece
* 15 - Croatia
* 16 - Hungary
* 17 - Ireland
* 18 - Israel
* 19 - Iceland
* 20 - Italy
* 21 - Lithuania
* 22 - Luxembourg
* 23 - Netherlands
* 24 - Norway
* 25 - Poland
* 26 - Portugal
* 27 - Russia
* 28 - Sweden 
* 29 - Slovenia
* 30 - Slovakia
* 31 - Turkey
* 32 - Ukraine
	
* efficacy measures
	* internal efficacy
		* polintr
		* actrolg (essround 7) actrolga (essrounds 8 & 9): How able do you think you are to take an active role in a group involved with political issues?
		* cptppol (essround 7) cptppola (essrounds 8 & 9): And how confident are you in your own ability to participate in politics?
	* external efficacy
		* psppsgv (essround 7) psppsgva (essrounds 8 & 9): How much would you say the political system in [country] allows people like you to have a say in what the government does? 
		* psppipl (essround 7) psppipla (essrounds 8 & 9): And how much would you say that the political system in [country] allows people like you to have an influence on politics?
	
* recode polintr for higher values to mean more interest
recode polintr (1=4) (2=3) (3=2) (4=1)
la define la_polintr 1 "Not at all interested " 2 "Hardly interested" 3 "Quite interested" 4 "Very interested" 
la val polintr la_polintr

* essround 7 efficacy measures are on a 10 pt scale and essrounds 8 & 9 on 5 pt
gen actrolg_new = actrolg
recode actrolg_new (0=1) (1=1) (2=2) (3=2) (4=3) (5=3) (6=3) (7=4) (8=4) (9=5) (10=5)
gen actrolg_5pt = actrolga
replace actrolg_5pt = actrolg_new if essround == 7 
drop actrolg_new
tab actrolg_5pt essround
la var actrolg_5pt "How able do you think you are to take an active role in a group involved with political issues?"

gen cptppol_new = cptppol
recode cptppol_new (0=1) (1=1) (2=2) (3=2) (4=3) (5=3) (6=3) (7=4) (8=4) (9=5) (10=5)
gen cptppol_5pt = cptppola
replace cptppol_5pt = cptppol_new if essround == 7 
drop cptppol_new
tab cptppol_5pt essround
la var cptppol_5pt "And how confident are you in your own ability to participate in politics?"

gen psppsgv_new = psppsgv
recode psppsgv_new (0=1) (1=1) (2=2) (3=2) (4=3) (5=3) (6=3) (7=4) (8=4) (9=5) (10=5)
gen psppsgv_5pt = psppsgva
replace psppsgv_5pt = psppsgv_new if essround == 7 
drop psppsgv_new
tab psppsgv_5pt essround
la var psppsgv_5pt "How much would you say the political system in [country] allows people like you to have a say in what the government does?" 
 
gen psppipl_new = psppipl
recode psppipl_new (0=1) (1=1) (2=2) (3=2) (4=3) (5=3) (6=3) (7=4) (8=4) (9=5) (10=5)
gen psppipl_5pt = psppipla
replace psppipl_5pt = psppipl_new if essround == 7 
drop psppipl_new
tab psppipl_5pt essround
la var psppipl_5pt "And how much would you say that the political system in [country] allows people like you to have an influence on politics?" 

* declare 'other' as mvs in education measures
mvdecode edulvla eisced, mv(55=.a)

* recode hincfel for higher values to mean higher subjective income
recode hincfel (1=4) (2=3) (3=2) (4=1)
la define la_hincfel 1 "Very difficult on present income" 2 "Difficult on present income" 3 "Coping on present income" 4 "Living comfortably on present income"
la val hincfel la_hincfel

* recode gincdif for higher values to mean stronger support
recode gincdif (1=5) (2=4) (3=3) (4=2) (5=2)
la define la_gincdif 1 "Disagree strongly " 2 "Disagree " 3 "Neither agree nor dis" 4 "Agree" 5 "Agree strongly"
la val gincdif la_gincdif

* recode unemployment
recode uemp3m (2=0) (1=1)
la define la_uemp3m 0 "No" 1 "Yes"
la val uemp3m la_uemp3m

* square age to account for a potential curvilinear relationship
gen age_sq = agea^2
la var age_sq "Age squared (former var agea)"

// INDICES //

* gen institutional trust idx
gen instrustidx = trstprl + trstlgl + trstplc + trstplt + trstprt
la var instrustidx "Institutional trust index (trstprl, trstlgl, trstplc, trstplt, trstprt)"
* alpha trstprl trstlgl trstplc trstplt trstprt
	* 0.8912
factor trstprl trstlgl trstplc trstplt trstprt, pcf
rotate, varimax

* gen immigration attitudes idx
gen immattidx = imsmetn + imdfetn + impcntr
la var immattidx "Immigration attitudes index (imsmetn, imdfetn, impcntr)"
* alpha imsmetn imdfetn impcntr
	* 0.8746	
	
* internal efficacy
	gen inteffidx_res = actrolg_5pt + cptppol_5pt
	la var inteffidx_res "Internal efficacy index (actrolg_5pt, cptppol_5pt)"
	alpha actrolg_5pt cptppol_5pt
	factor actrolg_5pt cptppol_5pt, pcf
	rotate, varimax

* external efficacy
	gen exteffidx = psppsgv_5pt + psppipl_5pt
	la var exteffidx "External efficacy index (psppsgv_5pt, psppipl_5pt)"
	alpha psppsgv_5pt psppipl_5pt
	factor psppsgv_5pt psppipl_5pt, pcf
	rotate, varimax	
	
/** DEFINE THE UNIVERSE OF CASES **/

* leave only rounds 7, 8, & 9
keep if essround == 7 | essround == 8 | essround == 9 	

save /*filepath*/, replace														//Save the dataset		
